using System;
using System.Collections.Generic;
using System.Text;
using Zoo.Domain;
using Zoo.DAL;

namespace Zoo.Mappers
{
    internal class UserMapper
    {
        internal static IdentityCard[] ToUserIdentityCards(ZooUserCollection zooUserCol)
        {
            IdentityCard[] userCards= new IdentityCard[zooUserCol.Count];
            for (int i = 0; i < zooUserCol.Count; i++)
            {
                userCards[i]= UserMapper.ToIdentityCard(zooUserCol[i]);

            }
            return userCards;
        }

        public static IdentityCard ToIdentityCard(ZooUser zooUser)
        {
            IdentityCard card = new IdentityCard();
            card.NickName = zooUser.NickName;
            card.UserID = zooUser.UserID;
            card.BornDate = zooUser.BornDate;
            card.City = zooUser.City;
            card.CountryCode = zooUser.Country.CountryName;
            card.Description = zooUser.Description;
            card.EmailAddress = zooUser.EmailAddress;
            card.GenderCode = zooUser.Gender;
            card.Language = zooUser.UserLanguage;
            card.LastLogin = zooUser.LastLogin;
            card.Online = zooUser.Online;
            card.RegionCode = zooUser.Region.RegionName;
            card.RegistrationDate = zooUser.RegistrationDate;
            card.SeekingCode = zooUser.Seeking;

            PictureCollection picCol = zooUser.Pictures();
            IPictureStorage pictureStorage = PictureStorageFactory.CreatePictureStorage();

            if (picCol.Count > 0)
                card.PictureUrl =  pictureStorage.GetPictureUrl(zooUser.Pictures()[0].PictureID);

           
           
            return card;
        }
    }
}
